---
id: linqexpression
title: 5. LinqExpression 静态类
sidebar_label: 5. LinqExpression 静态类
---

## 5.1 创建一个表达式

```cs
var expression = LinqExpression.Create<T>(u => u.Id == 1);
var expression2 = LinqExpression.Create<T>((u,i) => u.Id == 1 && i > 0);
```

## 5.2 拼接两个表达式

```cs
// 创建一个初始化的表达式
var expression = LinqExpression.And();
var expression2 = LinqExpression.IndexAnd();
var expression3 = LinqExpression.Or();
var expression4 = LinqExpression.IndexOr();

// 拼接表达式
var expression5 = expression.And(expression2);
var expression6 = expression.AndIf(age > 18, expression2);
var expression7 = expression.Or(expression2);
var expression8 = expression.OrIf(age > 18, expression2);

// 获取表达式属性名
var properyName = expression.GetExpressionPropertyName(u => u.Name);    // Name
```
